home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 3609 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  71 lines

  1. Path: Norway.EU.net!usenet
  2. From: patrick.hanevold@login.eunet.no (Patrick Hanevold)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Random Number Generation
  5. Date: 22 Feb 1996 07:02:34 GMT
  6. Organization: EUnet Norway
  7. Message-ID: <1294.6626T458T498@login.eunet.no>
  8. References: <199602071623.QAA00075@sable.ox.ac.uk> <Pine.OSF.3.91.960207175121.20357B-100000@hai.hiMolde.no>
  9.      <19960207.41F660.11A72@aj050.du.pipex.com> <1100.6613T1273T666@himolde.no>
  10.     <692.6619T1254T1752@in.net> <4g2bi9$1fls@rs18.hrz.th-darmstadt.de>
  11.     <19 <4ge27m$snj@daily-planet.execpc.com>
  12. NNTP-Posting-Host: pc9.asker-pm2-1.eunet.no
  13. X-Newsreader: THOR 2.22 (Amiga;TCP/IP)
  14.  
  15.  
  16. >: In theory, this is a very good suggestion.  In practice, rand() is a
  17. >: very poor RNG.  Run any common statistical tests on rand()'s output
  18. >: to see.
  19.  
  20. >The way that the orginal posting started by using srand() to the time,
  21. >one when using rand() gets a more random number (at least the random
  22. >numbers don't repeat in the same order each time.)
  23.  
  24. Here is a new one:
  25.  
  26. >Jeg har h°rt rykter om at noen svarte pσ mitt kall om en random rutine
  27. >(C/Asm)?!?! I sσfall har jeg gσtt glipp av det! :)
  28.  
  29. >Kan den personen slenge opp rutina en gang til?
  30.  
  31. >Takk...
  32.  
  33.  
  34. ; By Patrick Hanevold 5/1-1996
  35.  
  36. SetSeed MACRO
  37.         move.w  \1,rndbuf
  38.         ENDM
  39.  
  40. RND     MACRO
  41.         move.w  (a0),\1
  42.         move.w  2(a0,\1.l*2),\1
  43.         move.w  \1,(a0)
  44.         ENDM
  45.  
  46. Test    SetSeed #1996
  47.         bsr     InitRND
  48.         lea     rndbuf,a0
  49.         clr.l   d0
  50.         RND     d0
  51.         rts
  52.  
  53. InitRND lea     rndbuf,a0
  54.         move.w  (a0)+,d0        ; Seed
  55.         move.w  #-1,d7
  56.         moveq   #0,d1
  57. .loop   move.w  d0,d1
  58.         mulu    #9377,d0
  59.         add.w   #9439,d0
  60.         move.w  d0,(a0,d1.l*2)
  61.         dbra    d7,.loop
  62.         rts
  63.  
  64.         section BSS,BSS
  65. rndbuf  ds.w    $10001
  66.  
  67. <sb>Patrick Hanevold - Virtual Reality developer
  68. <sb>patrick.hanevold@login.eunet.no
  69. <sb>Amiga and official Be developer
  70.  
  71.